package com.ido.switchmodel.util

import android.content.Context

object SwitchModelPreferenceSetting {

    private const val PREFS_FILE = "switch_model_config"
    private const val HOT_TIME = "hot_time" //后台进入前台间隔时间
    private const val HOT_MODE = "hot_mode" //后台进入前台  0是关闭 1是闪屏  2是插屏


    fun getHotIntervalTime(context: Context): Int {
        val preferences = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE)
        return preferences.getInt(HOT_TIME, -1)
    }

    /*
     time 单位是秒
     */
    fun setHotIntervalTime(context: Context, time: Int) {
        val preferences = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE)
        preferences.edit().putInt(HOT_TIME, time).apply()
    }



    fun getHotMode(context: Context): Int {
        val preferences = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE)
        return preferences.getInt(HOT_MODE, -1)
    }

    /*
     0是关闭 1是闪屏  2是插屏
     */
    fun setHotMode(context: Context, mode: Int) {
        val preferences = context.getSharedPreferences(PREFS_FILE, Context.MODE_PRIVATE)
        preferences.edit().putInt(HOT_MODE, mode).apply()
    }
}